package com.qk.management.exception;

import com.qk.common.Result;
import com.qk.common.exception.BaseException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author 上官徵羽
 * @version 1.0
 * @since 2025-10-07 9:55
 */
@Slf4j
@RestControllerAdvice
public class MyGlobalExceptionHandler {

    @ExceptionHandler(BaseException.class)
    public Result handleException(BaseException e) {
        log.error("通用异常捕获：{}", e.getMessage());
        return Result.error(e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public Result handleException(Exception e) {
        log.error("全局异常捕获：{}", e.getMessage());
        return Result.error("网络异常波动,请稍后再试.");
    }


}
